/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 最终版学生成绩管理系统;

import java.io.*;

import javax.swing.JOptionPane;

public class TxtSave {
	
	public TxtSave(String txt,String title){
		if(txt.equals(""))
			JOptionPane.showMessageDialog(null, "缺少必要内容", "Massage",
					JOptionPane.INFORMATION_MESSAGE);
		else
		try{
		
				FileWriter fileWriter;
			    fileWriter = new FileWriter("D:\\学生成绩管理\\"+title+"学生信息.txt");
			    BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
			    bufferedWriter.write(txt);
			    bufferedWriter.flush();
			    bufferedWriter.close();
			    fileWriter.close();

			JOptionPane.showMessageDialog(null, "保存成功", "Massage",
					JOptionPane.INFORMATION_MESSAGE);
		}catch(IOException e){
			JOptionPane.showMessageDialog(null, e.getMessage(), "IOException:",
					JOptionPane.INFORMATION_MESSAGE);
		}
	}
}

